/**
 * @author LKQ
 * @date 2022/2/12 13:54
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.reformat("j"));
    }
    public String reformat(String s) {
        int n = s.length();
        if (n <= 1) {
            return s;
        }
        StringBuilder character = new StringBuilder();
        StringBuilder digit = new StringBuilder();
        for (char c: s.toCharArray()) {
            if (Character.isLetter(c)) {
                character.append(c);
            }else {
                digit.append(c);
            }
        }
        if (character.length() == 0 || digit.length() == 0 || Math.abs(character.length() - digit.length()) >= 2) {
            return "";
        }
        String ans = "";
        if (character.length() > digit.length()) {
            ans = combine(character.toString(), digit.toString(), n);
        }else {
            ans = combine(digit.toString(), character.toString(), n);
        }
        return ans;
    }

    public String combine(String character, String digit, int n) {
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < n ; i++) {
            if (i % 2 == 0) {
                ans.append(character.charAt(i / 2));
            }else {
                ans.append(digit.charAt((i - 1) / 2));
            }
        }
        return ans.toString();
    }
}
